<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ajax</title>
</head>
<body>
    <input type="text">
    <ul></ul>
    <script src="./ajax.js"></script>
    <script>
        document.querySelector('input').oninput=function(){
            let wd=this.value
            get('http://www.baidu.com/sugrec',`prod=pc&wd=${wd}`,rs=>{
                let ulObj=document.querySelector('ul')
                ulObj.innerText=''
                if(rs.g){
                    rs.g.forEach(item => {
                        let liObj=document.createElement('li')
                        liObj.innerText=item.q
                        ulObj.appendChild(liObj)
                    });
                }
            },xhr=>{})
        }
    </script>
</body>
</html>